package com.bearingnavi.android.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.CheckBox;
import com.bearingnavi.android.R;
import com.bearingnavi.android.util.Preferences;

public class SettingsDialog extends Dialog{

	private CheckBox followMe;
	private CheckBox rotateMap;
	
	public SettingsDialog(Context context) {
		
		super(context);		
	}
	
	@Override
	public void onBackPressed() {
		
		Preferences.getInstance().setFollowMe(followMe.isChecked());
		Preferences.getInstance().setRotateMap(rotateMap.isChecked());
		
		Preferences.getInstance().applyAllSettings();
    	
		super.onBackPressed();
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		
		this.setContentView(R.layout.settings);
		
		followMe = (CheckBox) findViewById(R.id.followMe);
		rotateMap = (CheckBox) findViewById(R.id.rotateMap);
		
		followMe.setChecked(Preferences.getInstance().getFollowMe());
		rotateMap.setChecked(Preferences.getInstance().getRotateMap());
						
	}
	
}
